
var hwPenWidth = 3;
var hwSignObj;

var hw = {

		load: function(id, winId){   
			console.log("load:", "汉王签字版控件运行");
			try{
				if(undefined != winId){
					hwSignObj = $('#' + winId)[0].contentDocument.getElementById(id); 
				} else {
					hwSignObj = document.getElementById(id); 
				}
				
				hwSignObj.HWSetBkColor(0xE0F8E0);  
				hwSignObj.HWSetCtlFrame(2, 0x000000);
				hwSignObj.HWSetPenWidth(hwPenWidth); 
				hw.init();
				//使用鼠标模式
				hw.mouseModel();
			} catch (ex) {
		    	console.log("load:", "签名屏加载异常");
		   }
		},
		
		/**
		 * 初始化
		 */
		init : function() {
//			HW_eOk                0           成功
//			HW_eDeviceNotFound   -1           未找到对应的汉王手写设备
//			HW_eFailedLoadModule -2           手写模块加载失败
//			HW_eFailedInitModule -3           手写模块初始化失败
//			HW_eWrongImageFormat -4           不支持的图片格式
//			HW_eNoSignData       -5           没有签名数据
//			HW_eInvalidInput     -6          无效输入参数
          try{
			  res = hwSignObj.HWInitialize();
			  console.log("init:", "签名屏控件初始化：", res);
          } catch (ex) {
	    	  console.log("init:", "签名屏初始化异常");
	      }
		},

		/**
		 * 关闭
		 */
		finalize : function() {
		   try {
			   var stream;
			   stream = hwSignObj.HWFinalize();
			   console.log("finalize:", "汉王签字版控件关闭");
	      } catch (ex) {
	    	  console.log("finalize:", "汉王签字版控件关闭异常");
	      }
		   
		},

		/**
		 * 清理
		 */
		clear : function() {
			console.log("clear:", "重新签名");
			hwSignObj.HWClearPenSign();
		},
		
		base64Img : function() {
			   var stream;
			   stream = hwSignObj.HWGetBase64Stream(2);
			   console.log("stream:", stream);
			   return stream;
		},
		
		//鼠标模式
		mouseModel : function(){
			hwSignObj.HWMouseEnable(1);
			console.log("mouseModel:", "鼠标模式运行");
		},
		
		//移至扩展屏
		switchSignMonitor : function() {
			try{
				hwSignObj.HWSwitchMonitor(1,0);
				//使用鼠标模式
				hw.mouseModel();
				console.log("switchSignMonitor:", "移至签名屏");
			} catch (ex) {
		    	  console.log("switchSignMonitor:", "移至签名屏异常");
		    }
		},
		
		//移回主显示器
		switchPCMonitor : function () {
			try{
				hwSignObj.HWMouseEnable(0);
				hwSignObj.HWSwitchMonitor(0,0);
				console.log("switchPCMonitor:", "移回显示器");
			} catch (ex) {
		    	  console.log("switchPCMonitor:", "移回显示器异常");
		    }
		}
    		
    }



